package com.water.tool;

/**
 * 自定义标签
 */
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.intranet.sys.domain.Menu;
import com.intranet.sys.service.MenuService;

@Controller
public class WaterPageTag extends TagSupport {

	@Autowired
	private MenuService menuService;

	private String parameter;

	public String getParameter() {
		return parameter;
	}

	public void setParameter(String parameter) {
		this.parameter = parameter;
	}

	@Override
	public int doStartTag() throws JspException {
		try {
			HttpServletRequest request = (HttpServletRequest) pageContext
					.getRequest();
			JspWriter out = pageContext.getOut();
			StringBuffer sb = new StringBuffer();
			sb
					.append("<li><i class='icon-home'></i><a href='index.do'>首页</a><i class='icon-angle-right'></i></li>");
			String[] menuPath = parameter.split("/");
			for (int i = 0; i < menuPath.length; i++) {
				sb.append("<li><a href='#'>" + menuPath[i] + "</a>");
				if (i != menuPath.length-1) {
					sb.append("<i class='icon-angle-right'></i>");
				}
				sb.append("</li>");
			}
			out.print(sb.toString());
		} catch (IOException e) {
			throw new JspTagException(e.getMessage());
		}
		return SKIP_BODY;
	}

}
